using System;
using System.ComponentModel.DataAnnotations.Schema;
using UwinEducation.Shared.Enums;

namespace UwinEducation.Domain.Entities
{
    /// <summary>
    /// 订单折扣实体
    /// </summary>
    [Table("order_discounts")]
    public class OrderDiscount : EntityBase
    {
        /// <summary>
        /// 折扣ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        public Guid OrderId { get; set; }


        /// <summary>
        /// 折扣金额
        /// </summary>
        public decimal DiscountAmount { get; set; }


        /// <summary>
        /// 折扣说明
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 订单导航属性
        /// </summary>
        public virtual Order Order { get; set; }
        
        //根据CreatedBy 获取创建人
        public virtual User Creator { get; set; }
        protected OrderDiscount() { }

        /// <summary>
        /// 创建折扣
        /// </summary>
        public static OrderDiscount CreateDiscount(
            Guid orderId,
            decimal discountAmount,
            string description = null)
        {
            return new OrderDiscount
            {
                Id = Guid.NewGuid(),
                OrderId = orderId,
                DiscountAmount = discountAmount,
                Description = description
            };
        }



    }


} 